package com.cskaoyan.controller.keyword;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Keyword;
import com.cskaoyan.bean.ListData;
import com.cskaoyan.service.keyword.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.controller
 * @date 2020/12/5 22:10
 * @Copyright © 暂时还没有
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeywordController {

    @Autowired
    KeywordService keywordService;

    @RequestMapping("update")
    public BaseRespVo keywordUpdate(@RequestBody Keyword keyword){

        Keyword keywordUpdate = keywordService.keywordUpdate(keyword);
        //返回修改后的该记录
        return BaseRespVo.ok(keywordUpdate);

    }
    @RequestMapping("list")
    public BaseRespVo keywordList
            (Integer page, Integer limit, String sort, String order,String keyword,String url){
        ListData<Keyword> listData = keywordService.keywordList(page, limit, sort, order, keyword, url);
        return BaseRespVo.ok(listData);
    }
    @RequestMapping("create")

    public BaseRespVo keywordCreate(@RequestBody Keyword keyword){
        //返回新增keyword对象

        Keyword keywordNew = keywordService.keywordCreate(keyword);

        return BaseRespVo.ok(keywordNew);
    }

    @RequestMapping("delete")
    public BaseRespVo keywordDelete(@RequestBody Keyword keyword){
        keywordService.keywordDelete(keyword);
        return BaseRespVo.ok();
    }
}
